package lecture;

import java.util.ArrayList;
import java.util.List;

import model.Course;
import employee.Employee;
import lecture.LectureEntity;
import model.Entity;

public class Lecture extends Entity{

	protected String code;
	protected float ects;
	protected float coeff;
	protected boolean optional = false;
	protected String level;
	protected Employee owner = null;
	protected List<LectureEntity> entities;
	protected List<Lecture> prerequisites;
	protected List<Course> sharedwith;
	
	public Lecture(){
		this.code = "Default";
		this.entities = new ArrayList<LectureEntity>();
		this.prerequisites = new ArrayList<Lecture>();
		this.sharedwith = new ArrayList<Course>();
	}

	public Lecture(String name, String code, float ects, float coeff, String level, Employee owner)
	{
		super(name);
		this.code = code;
		this.ects = ects;
		this.coeff = coeff;
		this.owner = owner;
		this.entities = new ArrayList<LectureEntity>();
		this.prerequisites = new ArrayList<Lecture>();
		this.sharedwith = new ArrayList<Course>();
	}
	
	public Lecture(String name)
	{
		this(name, "?", 0, 0, "?", null);
	}
	
	public void addEntity(LectureEntity le)
	{
		this.entities.add(le);
	}
	
	public boolean removeEntity(LectureEntity le)
	{
		return this.entities.remove(le);
	}
	
	public void addPrerequisites(Lecture l)
	{
		this.prerequisites.add(l);
	}
	
	public boolean removeEntity(Lecture l)
	{
		return this.prerequisites.remove(l);
	}
	
	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public float getEcts() {
		return ects;
	}

	public void setEcts(float ects) {
		this.ects = ects;
	}

	public float getCoeff() {
		return coeff;
	}

	public void setCoeff(float coeff) {
		this.coeff = coeff;
	}

	public boolean isOptional() {
		return optional;
	}

	public void setOptional(boolean optional) {
		this.optional = optional;
	}

	public String getLevel() {
		return level;
	}

	public void setLevel(String level) {
		this.level = level;
	}

	public Employee getOwner() {
		return owner;
	}

	public void setOwner(Employee owner) {
		this.owner = owner;
	}

	public List<LectureEntity> getEntities() {
		return entities;
	}

	public void setEntities(List<LectureEntity> entities) {
		this.entities = entities;
	}

	public List<Lecture> getPrerequisites() {
		return prerequisites;
	}

	public void setPrerequisites(List<Lecture> prerequisites) {
		this.prerequisites = prerequisites;
	}

	public List<Course> getSharedwith() {
		return sharedwith;
	}

	public void setSharedwith(List<Course> sharedwith) {
		this.sharedwith = sharedwith;
	}

	public boolean add(Course arg0) {
		return sharedwith.add(arg0);
	}

	public void clear() {
		sharedwith.clear();
	}

	public Course get(int arg0) {
		return sharedwith.get(arg0);
	}

	public boolean remove(Object arg0) {
		return sharedwith.remove(arg0);
	}

	public String toString()
	{
		StringBuilder tmp = new StringBuilder("Lecture");
		tmp.append("\nowner"); tmp.append(this.owner.getFirstName());tmp.append(" "); tmp.append(this.owner.getName());
		tmp.append("\nname: "); tmp.append(this.getName());
		tmp.append("\ncode: "); tmp.append(this.code);
		tmp.append("\nects: "); tmp.append(this.ects);
		tmp.append("\ncoeff: "); tmp.append(this.coeff);
		tmp.append("\noptional: "); tmp.append(this.optional ? "true":"false");
		tmp.append("\nlevel: "); tmp.append(this.level);
		tmp.append("\nlevel: "); tmp.append(this.level);
		tmp.append("\nentities: "); tmp.append(this.entities);
		tmp.append("\nprerequisites: "); for(Lecture l: this.prerequisites) {tmp.append(l.getName()); tmp.append(' ');};

		return tmp.toString();
	}
}
